package org.chen.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class NewsException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private ExceptionCodeEnum statusCode;

    public NewsException() {
        super();
    }

    // 带有状态码和消息的构造函数
    public NewsException(ExceptionCodeEnum statusCode, String message) {
        super(message);
        this.statusCode = statusCode;
    }

    public NewsException(ExceptionCodeEnum statusCode) {
        this.statusCode = statusCode;
    }

    // 仅带消息的构造函数
    public NewsException(String message) {
        super(message);
    }

    // 获取状态码的方法
    public ExceptionCodeEnum getStatusCode() {
        return statusCode;
    }
}
